package com.yuji.aacar.service;


import com.yuji.aacar.bean.request.AliGenJiFenRequest;
import com.yuji.aacar.bean.request.AliGenRequest;
import com.yuji.aacar.bean.request.BannerRequest;
import com.yuji.aacar.bean.request.GetAllBrandRequest;
import com.yuji.aacar.bean.request.GetDataVersionRequest;
import com.yuji.aacar.bean.request.GetMyCreditRequest;
import com.yuji.aacar.bean.request.GetRoomNameRequest;
import com.yuji.aacar.bean.request.GetSeriesListByNameRequest;
import com.yuji.aacar.bean.request.GetSeriesListRequest;
import com.yuji.aacar.bean.request.HotBrandRequest;
import com.yuji.aacar.bean.request.ImguploadRequest;
import com.yuji.aacar.bean.request.LogOutRequest;
import com.yuji.aacar.bean.request.LoginRequest;
import com.yuji.aacar.bean.request.ManagePersonalCarRequest;
import com.yuji.aacar.bean.request.ManagerCarAddressRequest;
import com.yuji.aacar.bean.request.MockRequest;
import com.yuji.aacar.bean.request.OrderDetailRequest;
import com.yuji.aacar.bean.request.OrderListRequest;
import com.yuji.aacar.bean.request.OrderSelectRequest;
import com.yuji.aacar.bean.request.PersonalCarListRequest;
import com.yuji.aacar.bean.request.QueryCarAddressRequest;
import com.yuji.aacar.bean.request.RegisterRequest;
import com.yuji.aacar.bean.request.ResetPasswordRequest;
import com.yuji.aacar.bean.request.RetrieveImageCodeRequest;
import com.yuji.aacar.bean.request.RetrieveTokenRequest;
import com.yuji.aacar.bean.request.SendShortMessageRequest;
import com.yuji.aacar.bean.request.SubmitRequest;
import com.yuji.aacar.bean.request.TokenRequest;
import com.yuji.aacar.bean.request.UpdateMemberRequest;
import com.yuji.aacar.bean.request.UpdatePersonalInfoRequest;
import com.yuji.aacar.bean.request.ValidatorCouponRequest;
import com.yuji.aacar.bean.request.ValidatorShortMessageRequest;
import com.yuji.aacar.bean.request.VersionRequest;
import com.yuji.aacar.bean.request.WashCarIndexRequest;
import com.yuji.aacar.core.cores.services.CoreServiceMediator;
import com.yuji.aacar.core.cores.services.Field_Method_Parameter_Annotation;
import com.yuji.aacar.core.mvvm.appbase.CoreBaseViewModel;
import com.yuji.aacar.net.bean.HttpCoreBaseRequest;

/**
 * <li>Package:com.ttp.boss.service
 * <li>Author: lining
 * <li>Date: 2017/2/21
 * <li>Description:
 */

public class BaseServiceMediator extends CoreServiceMediator implements IBaseServiceMediator {

    //用户管理
    public static final String LOGIN = "login";//登录
    public static final String FORGET_PASSWORD = "forgetpassword";//忘记密码
    public static final String USER_REGIST = "register";//用户注册
    public static final String CHANGE_PASSWORD = "updatePersonalInfo";//修改密码
    public static final String USER_LOGIN_OUT = "loginOut";//用户注销
    public static final String RESET_PASSWORD = "resetpassword";//重置密码
    public static final String IMAGE_UPLOAD = "imgupload";//上传头像
    public static final String UPDATE_MEMBER = "update_member";//保存用户信息
    public static final String UPDATE_DEVICETOKEN = "update_devicetokens";//保存用户信息

    //产品管理

    public static final String SELECT = "select";//查询产品价格

    //订单
    public static final String SUBMIT = "submit";//提交订单
    public static final String LIST = "list";//订单列表
    public static final String DETAIL = "detail";//订单列表
    public static final String ALI_GEN = "gen_alipay_paystr";//阿里串
    public static final String MOCK = "mock";//阿里回调
    public static final String WX_GEN = "gen_weixin_paystr_order";//阿里回调
    public static final String CANCEL = "cancel";//取消订单
    public static final String ALI_JIFEN_PAY = "gen_alipay_paystr_order_uip";//阿里积分支付
    public static final String WX_JIFEN_PAY = "gen_weixin_paystr_order_uip";//阿里积分支付

    //通用模块
    public static final String SEND_SHORT_MESSAGE = "sendshortmessage";//发送短信验证码
    public static final String VALIDATOR_SHORT_MESSAGE = "validatorshortmessage";//验证手机号和短信验证码
    public static final String RETRIVE_IMAGE_CODE = "retrieveImageCode";//获取图片验证码
    public static final String IS_EXIST_PHONE_NO = "is_exist_phoneNo";//获取图片验证码
    public static final String RETRIVE_TOKEN = "retrieveToken";//获取TOKEN
    public static final String COMPARE_APP_VERSION = "compareAppVersion";//版本检测
    public static final String GET_ALL_BRAND = "getAllBrand";//获取所有品牌
    public static final String GET_HOT_BRAND = "getHotBrand";//获取热门品牌
    public static final String GET_DATA_VERSION = "getDataVersion";//获取数据初始版本
    public static final String GET_SERIES_LIST = "getSeriesList";//获取车系
    public static final String GET_SERIES_LIST_BYNAME = "getSeriesByName";//根据品牌获取车系
    //    public static final String FORGET_PASSWORD = "forgetpassword";//忘记密码
        public static final String GET_ROOM_NAME = "getRoomName";//获取小区地址


    //首页
    public static final String GET_HOME_BANNER = "getHomePageBanner";//获取banner
    public static final String VALIDATOR_COUPON = "validatorCoupon";//校验优惠券是否正确
    public static final String GET_WASH_INDEX = "getWashIndex";//获取天气洗车状况


    //我的
    public static final String MANAGER_CAR_ADDRESS = "managerCarAddress";//增加、修改、删除洗车列表
    public static final String MANAGER_CAR_ADDRESS_DELETE = "managerCarAddress";//增加、修改、删除洗车列表
    public static final String MANAGER_CAR_ADDRESS_EDIT = "managerCarAddress";//增加、修改、删除洗车列表
    public static final String QUERY_CAR_ADDRESS = "queryCarAddress";//查看洗车列表
    public static final String GET_PERSONAL_CAR_LIST = "getPersonalCarList";//获取个人车列表
    public static final String MANAGE_PERSONAL_CAR = "managePersonalCar";//增加、修改、删除车辆列表
    public static final String GET_MY_CREDIT = "getMyCredit";//用户积分余额


    public BaseServiceMediator() {
    }

    public BaseServiceMediator(CoreBaseViewModel viewModel) {
        super(viewModel);
    }


    //    @Field_Method_Parameter_Annotation(args = {"version", "type", "uuUserId"})
    //    public static HttpCoreBaseRequest getversion() throws Exception {
    //        VersionRequestData request = new VersionRequestData();
    //        request.setVersion(AppInfo.getVersion());
    //        request.setType(AppInfo.getDeviceType());
    //        request.setUuUserId(AppInfo.getUuUserId());
    //        request.setCode(VERSION_CODE);
    //        return request;
    //    }

    /*************用户管理**************/
    @Field_Method_Parameter_Annotation(args = {"phoneNo", "passWord"})
    public static HttpCoreBaseRequest login(String phoneNo, String passWord) {
        LoginRequest request = new LoginRequest();
        request.setPhoneNo(phoneNo);
        request.setPassWord(passWord);
        request.setRequestCode(LOGIN_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"phoneNo", "passWord"})
    public static HttpCoreBaseRequest forgetpassword(String userName, String passWord) {
        LoginRequest request = new LoginRequest();
        request.setPhoneNo(userName);
        request.setPassWord(passWord);
        request.setRequestCode(FORGET_PASSWORD_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"phoneNo", "passWord", "newPassWord", "code"})
    public static HttpCoreBaseRequest register(String userName, String passWord, String newPassWord, String code) {
        RegisterRequest request = new RegisterRequest();
        request.setPhoneNo(userName);
        request.setPassWord(passWord);
        request.setNewPassWord(newPassWord);
        request.setCode(code);
        request.setRequestCode(USER_REGIST_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"passWord", "confirmPassWord", "newPassword"})
    public static HttpCoreBaseRequest updatePersonalInfo(String passWord, String confirmPassWord, String newPassword) {
        UpdatePersonalInfoRequest request = new UpdatePersonalInfoRequest();
        request.setPassWord(passWord);
        request.setConfirmPassWord(confirmPassWord);
        request.setNewPassword(newPassword);
        request.setRequestCode(CHANGE_PASSWORD_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest loginOut() {
        LogOutRequest request = new LogOutRequest();
        request.setRequestCode(USER_LOGIN_OUT_CODE);
        return request;
    }

    //登录手机号？？？
    @Field_Method_Parameter_Annotation(args = {"phoneNo", "passWord", "newPassWord", "code"})
    public static HttpCoreBaseRequest resetpassword(String userName, String passWord, String newPassWord, String code) {
        ResetPasswordRequest request = new ResetPasswordRequest();
        request.setPhoneNo(userName);
        request.setPassWord(passWord);
        request.setNewPassWord(newPassWord);
        request.setCode(code);
        request.setRequestCode(RESET_PASSWORD_CODE);
        return request;
    }


    @Field_Method_Parameter_Annotation(args = {"flag", "base64Code"})
    public static HttpCoreBaseRequest imgupload(String flag, String base64Code) {
        ImguploadRequest request = new ImguploadRequest();
        request.setFlag(flag);
        request.setBase64Code(base64Code);
        request.setRequestCode(UPLOAD_IMAGE_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"nickName", "loginName", "sex"})
    public static HttpCoreBaseRequest update_member(String nickName, String loginName, String sex) {
        UpdateMemberRequest request = new UpdateMemberRequest();
        request.setNickName(nickName);
        request.setLoginName(loginName);
        request.setSex(sex);
        request.setRequestCode(UPDATE_MEMBER_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"deviceTokens"})
    public static HttpCoreBaseRequest update_devicetokens(String deviceTokens) {
        TokenRequest request = new TokenRequest();
        request.setDeviceTokens(deviceTokens);
        request.setRequestCode(BIND_TOKEN_CODE);
        return request;
    }


    /*************通用模块**************/

    @Field_Method_Parameter_Annotation(args = {"phoneNo", "flag"})
    public static HttpCoreBaseRequest sendshortmessage(String phoneNo, String flag) {
        SendShortMessageRequest request = new SendShortMessageRequest();
        request.setPhoneNo(phoneNo);
        request.setFlag(flag);
        request.setRequestCode(SEND_CHECK_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"phoneNo", "code", "flag"})
    public static HttpCoreBaseRequest validatorshortmessage(String phoneNo, String code, String flag) {
        ValidatorShortMessageRequest request = new ValidatorShortMessageRequest();
        request.setPhoneNo(phoneNo);
        request.setCode(code);
        request.setFlag(flag);
        request.setRequestCode(CHECK_CHECK_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"phoneNo", "type"})
    public static HttpCoreBaseRequest retrieveImageCode(String phoneNo, String type) {
        RetrieveImageCodeRequest request = new RetrieveImageCodeRequest();
        request.setPhoneNo(phoneNo);
        request.setType(type);
        request.setRequestCode(GET_IMAGECODE_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest retrieveToken() {
        RetrieveTokenRequest request = new RetrieveTokenRequest();
        request.setRequestCode(GET_TOKEN_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest compareAppVersion() {
        VersionRequest request = new VersionRequest();
        request.setRequestCode(COMPARE_APP_VERSION_CODE);
        return request;
    }
    @Field_Method_Parameter_Annotation(args = {"pageNo", "pageSize"})
    public static HttpCoreBaseRequest getAllBrand(String pageNo, String pageSize) {
        GetAllBrandRequest request = new GetAllBrandRequest();
        request.setPageNo(pageNo);
        request.setPageSize(pageSize);
        request.setRequestCode(GET_ALL_BRAND_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest getHotBrand() {
        HotBrandRequest request = new HotBrandRequest();
        request.setRequestCode(GET_HOT_BRAND_CODE);
        return request;
    }
    @Field_Method_Parameter_Annotation(args = {"tableName"})
    public static HttpCoreBaseRequest getDataVersion(String tableName) {
        GetDataVersionRequest request = new GetDataVersionRequest();
        request.setTableName(tableName);
        request.setRequestCode(GET_DATA_VERSION_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"brandId"})
    public static HttpCoreBaseRequest getSeriesList(String brandId) {
        GetSeriesListRequest request = new GetSeriesListRequest();
        request.setBrandId(brandId);
        request.setRequestCode(GET_SERIES_LIST_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"brandName"})
    public static HttpCoreBaseRequest getSeriesByName(String brandName) {
        GetSeriesListByNameRequest request = new GetSeriesListByNameRequest();
        request.setBrandName(brandName);
        request.setRequestCode(GET_SERIES_LIST_BYNAME_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest getRoomName() {
        GetRoomNameRequest request = new GetRoomNameRequest();
        request.setRequestCode(GET_ROOM_NAME_CODE);
        return request;
    }



    /*************产品**************/

    @Field_Method_Parameter_Annotation(args = {"carType", "carLibType", "provinceCode", "cityCode", "areaCode", "roomCode", "bookStartTime", "bookEndTime"})
    public static HttpCoreBaseRequest select(String carType, String carLibType, String provinceCode,
                                             String cityCode, String areaCode,String roomCode,String bookStartTime,String bookEndTime) {
        OrderSelectRequest request = new OrderSelectRequest();
        request.setCarType(carType);
        request.setCarLibType(carLibType);
        request.setProvinceCode(provinceCode);
        request.setCityCode(cityCode);
        request.setAreaCode(areaCode);
        request.setRoomCode(roomCode);
        request.setBookStartTime(bookStartTime);
        request.setBookEndTime(bookEndTime);
        request.setRequestCode(SELECT_CODE);
        return request;
    }

    /*************订单**************/
    @Field_Method_Parameter_Annotation(args = {"order"})
    public static HttpCoreBaseRequest submit(SubmitRequest order) {
//        SubmitRequest request = new SubmitRequest();
//        request.setOrder(order);
        order.resetOrderValue();
        order.setRequestCode(SUBMIT_CODE);
        return order;
    }


    @Field_Method_Parameter_Annotation(args = {"pageNumber","pageSize"})
    public static HttpCoreBaseRequest list(String pageNumber, String pageSize) {
        OrderListRequest request = new OrderListRequest();
        request.setPageSize(pageSize);
        request.setPageNumber(pageNumber);
        request.setRequestCode(LIST_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"orderNo"})
    public static HttpCoreBaseRequest detail(String orderNo) {
        OrderDetailRequest request = new OrderDetailRequest();
        request.setOrderNo(orderNo);
        request.setRequestCode(DETAIL_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"orderNo"})
    public static HttpCoreBaseRequest gen_alipay_paystr(String orderNo) {
        AliGenRequest request = new AliGenRequest();
        request.setOrderNo(orderNo);
        request.setRequestCode(ALI_GEN_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"out_trade_no"})
    public static HttpCoreBaseRequest mock(String out_trade_no) {
        MockRequest request = new MockRequest();
        request.setOut_trade_no(out_trade_no);
        request.setRequestCode(MOCK_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"orderNo"})
    public static HttpCoreBaseRequest gen_weixin_paystr_order(String orderNo) {
        AliGenRequest request = new AliGenRequest();
        request.setOrderNo(orderNo);
        request.setRequestCode(WX_GEN_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"orderNo"})
    public static HttpCoreBaseRequest cancel(String orderNo) {
        AliGenRequest request = new AliGenRequest();
        request.setOrderNo(orderNo);
        request.setRequestCode(CANCEL_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"integral","rechargeType"})
    public static HttpCoreBaseRequest gen_alipay_paystr_order_uip(String integral, String rechargeType) {
        AliGenJiFenRequest request = new AliGenJiFenRequest();
        request.setIntegral(integral);
        request.setRechargeType(rechargeType);
        request.setRequestCode(ALI_JIFEN_PAY_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"integral","rechargeType"})
    public static HttpCoreBaseRequest gen_weixin_paystr_order_uip(String integral, String rechargeType) {
        AliGenJiFenRequest request = new AliGenJiFenRequest();
        request.setIntegral(integral);
        request.setRechargeType(rechargeType);
        request.setRequestCode(WX_JIFEN_PAY_CODE);
        return request;
    }



    /*************首页**************/
    @Field_Method_Parameter_Annotation(args = {"phoneNo", "type"})
    public static HttpCoreBaseRequest getHomePageBanner(String phoneNo, String type) {
        BannerRequest request = new BannerRequest();
        request.setRequestCode(GET_HOMEPAGE_BANNER_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"couponNo", "couponPassword"})
    public static HttpCoreBaseRequest validatorCoupon(String couponNo, String couponPassword) {
        ValidatorCouponRequest request = new ValidatorCouponRequest();
        request.setCouponNo(couponNo);
        request.setCouponPassword(couponPassword);
        request.setRequestCode(VALIDATOR_COUPON_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"cityName"})
    public static HttpCoreBaseRequest getWashIndex(String cityName) {
        WashCarIndexRequest request = new WashCarIndexRequest();
        request.setCityName(cityName);
        request.setRequestCode(GET_WASH_INDEX_CODE);
        return request;
    }


    /*************我的**************/

    @Field_Method_Parameter_Annotation(args = {"addrType", "areaCode", "areaName", "cityCode", "cityName", "contactName",
            "contactNo", "detailAddress", "isDefault", "operateFlag", "phoneNo", "provinceCode", "provinceName","roomName","roomCode","pid"
    })
    public static HttpCoreBaseRequest managerCarAddress(String addrType, String areaCode, String areaName, String cityCode, String cityName,
                                                        String contactName, String contactNo, String detailAddress, String isDefault, String operateFlag, String phoneNo
            , String provinceCode, String provinceName, String roomName, String roomCode, String pid) {
        ManagerCarAddressRequest request = new ManagerCarAddressRequest();
        request.setAddrType(addrType);
        request.setAreaCode(areaCode);
        request.setAreaName(areaName);
        request.setCityCode(cityCode);
        request.setCityName(cityName);
        request.setContactName(contactName);
        request.setContactNo(contactNo);
        request.setDetailAddress(detailAddress);
        request.setIsDefault(isDefault);
        request.setOperateFlag(operateFlag);////1.表示新增 2.表示修改 3.表示删除
        request.setPhoneNo(phoneNo);
        request.setRoomName(roomName);
        request.setRoomCode(roomCode);
        request.setProvinceName(provinceName);
        request.setProvinceCode(provinceCode);
        request.setPid(pid);

        switch (Integer.parseInt(operateFlag)){
            case 1:
                request.setRequestCode(MANGE_CAR_ADDRESS_NEW);
                break;
            case 2:
                request.setRequestCode(MANGE_CAR_ADDRESS_MODIFY);
                break;
            case 3:
                request.setRequestCode(MANGE_CAR_ADDRESS_DELETE);
                break;
        }

        return request;
    }

    @Field_Method_Parameter_Annotation(args = {"pageSize", "pageNo"})
    public static HttpCoreBaseRequest queryCarAddress(String pageSize, String pageNo) {
        QueryCarAddressRequest request = new QueryCarAddressRequest();
        request.setPageSize(pageSize);
        request.setPageNo(pageNo);
        request.setRequestCode(QUERY_CAR_ADDRESS_CODE);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest getPersonalCarList() {
        PersonalCarListRequest request = new PersonalCarListRequest();
        request.setRequestCode(MANAGER_PERSONAL_CAR_LIST);
        return request;
    }

    @Field_Method_Parameter_Annotation(args = {})
    public static HttpCoreBaseRequest getMyCredit() {
        GetMyCreditRequest request = new GetMyCreditRequest();
        request.setRequestCode(GET_MY_CREDIT_CODE);
        return request;
    }

//    @Field_Method_Parameter_Annotation(args = {})
//    public static HttpCoreBaseRequest getPersonalCarList() {
//        QueryCarAddressRequest request = new QueryCarAddressRequest();
//        request.setRequestCode(MANAGER_PERSONAL_CAR_NEW);
//        return request;
//    }
//
//
//    @Field_Method_Parameter_Annotation(args = {})
//    public static HttpCoreBaseRequest getPersonalCarList() {
//        QueryCarAddressRequest request = new QueryCarAddressRequest();
//        request.setRequestCode(MANAGER_PERSONAL_CAR_DELETE);
//        return request;
//    }


    @Field_Method_Parameter_Annotation(args = {"request"})
    public static HttpCoreBaseRequest managePersonalCar(ManagePersonalCarRequest request) {
        int type = Integer.parseInt(request.getOperatorFlag());
        switch (type){
            case 1:
                request.setRequestCode(MANAGER_PERSONAL_CAR_NEW);
                break;
            case 2:
//                request.setRequestCode(MANAGER_PERSONAL_CAR_NEW);
                break;
            case 3:
                request.setRequestCode(MANAGER_PERSONAL_CAR_DELETE);
                break;
        }

        return request;
    }

}
